package com.dc2013.adapter;



import com.dc2013.followme.R;

import android.content.Context;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.LayoutParams;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class ViewPagerAdapter extends PagerAdapter
{
	LayoutInflater mInflater;
	Context context;


	public ViewPagerAdapter(Context c) 
	{
		super();
		this.context = c;
		mInflater = LayoutInflater.from(c);
	}

	@Override
	public int getCount() 
	{ // view의 개수
		return 4;
	}

	@Override
	public boolean isViewFromObject(View pager, Object obj)
	{ // instantiateItem에서
																// 생성한 객체를 이용할
																// 것인지 여부를 반환
		return pager == obj;
	}

	@Override
	public Object instantiateItem(ViewGroup container, final int position)
	{ // view를 등록한다.
		View v = null;
		
		ImageView img = new ImageView(context);
		img.setImageResource(R.drawable.img2); // position(페이지 위치 값마다의 이미지 세팅
		
		container.addView(img, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);


		return img;
	}

	@Override
	public void restoreState(android.os.Parcelable arg0, ClassLoader arg1) {
	}

	@Override
	public Parcelable saveState() 
	{
		return null;
	}

	@Override
	public void startUpdate(View arg0)
	{
	}

	@Override
	public void finishUpdate(View arg0) 
	{
	}

	@Override
	public float getPageWidth(int position) 
	{
		return 0.9f;
	} // 스택 구현 시 중요부분, 숫자가 작아질수록 여백이 커진다.
	
	@Override
	public void destroyItem(View pager, int position, Object view) 
	{	
		//((ViewPager)pager).removeView((View)view);
	}
	
}
